package com.demo;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.env.Environment;

import java.util.Objects;

public class MyCommandLineRunner implements CommandLineRunner {
    Environment environment;

    public MyCommandLineRunner(Environment environment) {
        this.environment = environment;
    }

    @Override
    public void run(String... args) throws Exception {
        System.out.println("这是SpringBoot自动装配的CommandLineRunner");
        System.out.println("===============MyCommandLineRunner==================");
        System.out.println("生成一个32位随机字符串:".concat(Objects.requireNonNull(environment.getProperty("random."))));
    }
}
